package com.cy.pj.sys.controller;

import com.cy.pj.common.pojo.JsonResult;
import com.cy.pj.sys.pojo.SysBook;
import com.cy.pj.sys.pojo.SysUser;
import com.cy.pj.sys.service.SysBookService;
import com.cy.pj.sys.service.SysUserService;
import org.apache.shiro.SecurityUtils;
import org.apache.shiro.authc.UsernamePasswordToken;
import org.apache.shiro.subject.Subject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

@RequestMapping("/book/")
@RestController
public class SysBookController {

    @Autowired
    private SysBookService sysBookService;


    @RequestMapping("doFindPageObjects")
    public JsonResult doFindPageObjects(String name, Long pageCurrent){
        return new JsonResult(sysBookService.findPageObjects(name, pageCurrent));
    }


    @RequestMapping("doSaveObject")
    public JsonResult doSaveObject(SysBook sysBook){
        sysBookService.saveObject(sysBook);
        return new JsonResult("Save OK");
    }


    @RequestMapping("doFindObjectById")
    public JsonResult doFindObjectById(Integer id){
        Map<String,Object> map=
                sysBookService.findObjectById(id);
        return new JsonResult(map);
    }



    @RequestMapping("doUpdateObject")
    public JsonResult doUpdateObject(SysBook sysBook){
        sysBookService.updateObject(sysBook);
        return new JsonResult("Update OK");
    }






}
